<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <title>被考核部门主页</title>
    <link href="lib/bootstrap/css/bootstrap.min.css" rel="stylesheet">
    <link href="lib/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
    <link href="lib/website/tb-page.css" rel="stylesheet">
    <style type="text/css">
    .form-horizontal .control-label {
        text-align: left;
    }

    .u-upload {
        display: inline-block;
        *display: inline;
        *zoom: 1;
        position: relative;
        overflow: hidden;
    }

    .u-upload button {
        height: 32px;
        padding: 0 10px;
        border: 1px solid #ccc;
        overflow: visible;
        font-size: 14px;
        color: #666;
        background: #ddd;
    }

    .u-upload input {
        position: absolute;
        top: 0;
        right: -1px;
        font-size: 100px;
        cursor: pointer;
        opacity: 0;
        filter: alpha(opacity=0);
    }

    .u-upload:hover button {
        border-color: #bbb;
        color: #333;
        background: #ccc;
    }

    a.u-upload,
    a.u-upload:hover {
        text-decoration: none;
    }
    </style>
</head>

<body>
    <div class="container-fluid">
        <div class="row header">
            <div class="col-md-8 col-sm-8">
                <h3>辽宁环保攻坚考核系统</h3>
            </div>
            <div class="col-md-4 col-sm-4 ">
                <h6 class="text-right">欢迎您! XX管理员@XXX.com</h6>
            </div>
        </div>
        <div class="row">
            <nav class="navbar navbar-default">
                <div class="navbar-header">
                    <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar-top">
                        <span class="sr-only">Toggle navigation</span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                    </button>
                    <a class="navbar-brand" href="#">辽宁环保攻坚考核系统</a>
                </div>
                <div class="collapse navbar-collapse" id="navbar-top">
                    <ul class="nav navbar-nav">
                        <li><a href="index.html">考核结果</a></li>
                        <li><a href="assess-department.html">考核评分</a></li>
                        <li class="active"><a href="assessed.html">数据上报</a></li>
                        <li><a href="dataAnalysis.html">数据分析</a></li>
                        <li><a href="userCenter.html">用户管理</a></li>
                    </ul>
                </div>
            </nav>
        </div>
        <div class="content">
            <div class="row">
                <div class="col-md-12">
                    <form class="form-horizontal">
                        <fieldset>
                            <div class="form-group">
                                <div class="col-md-1">
                                    <label for="inputEmail" class="control-label"><i class="glyphicon glyphicon-play text-primary"></i> 考核大类</label>
                                </div>
                                <div class="col-md-11">
                                        <label class="checkbox-ex"><input type="checkbox" class="sort" value="大气污染防治"> 大气污染防治&nbsp;&nbsp;</label>&nbsp;&nbsp;
                                        <label class="checkbox-ex"><input type="checkbox" class="sort" value="水污染防治"> 水污染防治</label>&nbsp;&nbsp;
                                        <label class="checkbox-ex"><input type="checkbox" class="sort" value="土壤污染防治"> 土壤污染防治</label>&nbsp;&nbsp;
                                        <label class="checkbox-ex"><input type="checkbox" class="sort" value="农业农村污染治理"> 农业农村污染治理</label>&nbsp;&nbsp;
                                        <label class="checkbox-ex"><input type="checkbox" class="sort" value="主要污染物减排"> 主要污染物减排</label>&nbsp;&nbsp;
                                        <label class="checkbox-ex"><input type="checkbox" class="sort" value="生态红线和自然保护区"> 生态红线和自然保护区</label>&nbsp;&nbsp;
                                        <label class="checkbox-ex"><input type="checkbox" class="sort" value="环境风险和信访办理"> 环境风险和信访办理</label>&nbsp;&nbsp;
                                        <label class="checkbox-ex"><input type="checkbox" class="sort" value="生态环境治理"> 生态环境治理</label>&nbsp;&nbsp;
                                        <label class="checkbox-ex"><input type="checkbox" class="sort" value="执法队伍和执法工作"> 执法队伍和执法工作</label>&nbsp;&nbsp;
                                        <label class="checkbox-ex"><input type="checkbox" class="sort" value="生态制度建设和保护责任落实"> 生态制度建设和保护责任落实</label>&nbsp;&nbsp;
                                        <label class="checkbox-ex"><input type="checkbox" class="sort" value="近岸海域综合治理"> 近岸海域综合治理</label>&nbsp;&nbsp;
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="inputPassword" class="col-md-1 control-label"><i class="glyphicon glyphicon-play text-primary"></i> 牵头考核部门</label>
                                <div class="col-md-11">
                                    <div class="checkbox">
                                        <label class='checkbox-ex'><input type="checkbox" class="sort1" value="省环保厅"> 省环保厅</label>&nbsp;&nbsp;
                                        <label class='checkbox-ex'><input type="checkbox" class="sort1" value="省发改委"> 省发改委</label>&nbsp;&nbsp;
                                        <label class='checkbox-ex'><input type="checkbox" class="sort1" value="省住建厅"> 省住建厅</label>&nbsp;&nbsp;
                                        <label class='checkbox-ex'><input type="checkbox" class="sort1" value="省信工委"> 省信工委</label>&nbsp;&nbsp;
                                        <label class='checkbox-ex'><input type="checkbox" class="sort1" value="省工商局"> 省工商局</label>&nbsp;&nbsp;
                                        <label class='checkbox-ex'><input type="checkbox" class="sort1" value="省质监局"> 省质监局</label>&nbsp;&nbsp;
                                        <label class='checkbox-ex'><input type="checkbox" class="sort1" value="省交通厅"> 省交通厅</label>&nbsp;&nbsp;
                                        <label class='checkbox-ex'><input type="checkbox" class="sort1" value="省农委"> 省农委</label>&nbsp;&nbsp;
                                        <label class='checkbox-ex'><input type="checkbox" class="sort1" value="省国土资源厅"> 省国土资源厅</label>&nbsp;&nbsp;
                                        <label class='checkbox-ex'><input type="checkbox" class="sort1" value="省水利厅"> 省水利厅</label>&nbsp;&nbsp;
                                        <label class='checkbox-ex'><input type="checkbox" class="sort1" value="省财政厅"> 省财政厅</label>&nbsp;&nbsp;
                                        <label class='checkbox-ex'><input type="checkbox" class="sort1" value="省畜牧局"> 省畜牧局</label>&nbsp;&nbsp;
                                        <label class='checkbox-ex'><input type="checkbox" class="sort1" value="省海洋与渔业厅"> 省海洋与渔业厅</label>&nbsp;&nbsp;
                                        <label class='checkbox-ex'><input type="checkbox" class="sort1" value="大连海事局"> 大连海事局</label>&nbsp;&nbsp;
                                    </div>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-md-1 control-label"><i class="glyphicon glyphicon-play text-primary"></i> 是否上报</label>
                                <div class="col-md-3">
                                    <div class="radio">
                                        <label><input type="radio" name="radios" class="radios" value=1> 已经上报 </label>
                                        <label><input type="radio" name="radios" class="radios" value=0> 未上报 </label>
                                        <label><input type="radio" name="radios" class="radios" value=2> 全部 </label>
                                    </div>
                                </div>
                            </div>
                        </fieldset>
                    </form>
                </div>
            </div>
            <div class="row">
                <div class="col-md-12">
                    <div class="well well-sm info">贵单位有<a href="javascript:void(0);" id="count">25</a>个考核指标文件未上报, 请及时上报</div>
                </div>
            </div>
            <div class="row">
                <div class="col-md-12">
                    <table class="table table-striped table-hover table-bordered" id="table">
                        <thead>
                            <tr>
                                <th>考核大类</th>
                                <th>重点任务</th>
                                <th>考核指标</th>
                                <th>是否上报</th>
                                <th>考核牵头部门</th>
                                <th>操作</th>
                            </tr>
                        </thead>
                    </table>
                </div>
            </div>
        </div>
        <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                        <h4 class="modal-title" id="myModalLabel">文件上传</h4>
                    </div>
                    <div class="modal-body">
                        <form action="http://39.98.42.158/manage/uploadFile" method="post" enctype="multipart/form-data">
                            <input type="text" value="环境空气质量达标率" name="assessmentIndicatorsName">
                            <input type="file" name="file" />
                            <input type="submit" value="上传文件" />
                        </form>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                        <button type="button" class="btn btn-primary">提交更改</button>
                    </div>
                </div><!-- /.modal-content -->
            </div><!-- /.modal -->
        </div>
    </div>
</body>
<script src="lib/jquery/jquery.1.10.2.min.js"></script>
<script src="lib/bootstrap/js/bootstrap.min.js"></script>
<script src="lib/bootstrap-table/bootstrap-table.min.js"></script>
<script src="lib/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>
<script src="lib/website/function.js"></script>
<script src="lib/jquery/ajaxfileupload.js"></script>
<script type="text/javascript">
/**
 * 获取复选框值
 * @param
 * @returns {*}
 */
function getCheckBoxVal() { //jquery获取所有选中的复选框的值 
    var checkValue = [];
    $(".checkbox-ex").find('input:checkbox').each(function() { //遍历所有复选框
        if ($(this).prop('checked') == true) {
            if (checkValue['tScoringTableName']) {
                if ($(this).attr('class') == 'sort') {
                    checkValue['tScoringTableName'] = checkValue['tScoringTableName'] + ',' + $(this).val();
                }
            } else {
                if ($(this).attr('class') == 'sort') {
                    checkValue['tScoringTableName'] = $(this).val();
                }
            }
            if (checkValue['leaderDepartmentName']) {
                if ($(this).attr('class') == 'sort1') {
                    checkValue['leaderDepartmentName'] = checkValue['leaderDepartmentName'] + ',' + $(this).val();
                }

            } else {
                if ($(this).attr('class') == 'sort1') {
                    checkValue['leaderDepartmentName'] = $(this).val();
                }

            }
        }
    });
    return checkValue;
}

/**
 * 获取单选框值
 * @param $this
 * @returns {*}
 */
function getRadioVal() {
    return $("input[name='radios']:checked").val();;
}

function uploadData(value, index) {
    var url = 'http://39.98.42.158/manage/uploadFile';
    var target = JSON.parse(value)

    // assessmentDepartmentName='+value.areaName+'&assessmentIndicatorsName='+value.assessmentIndicatorsName
    $.ajaxFileUpload({
        url: url, //后台请求地址
        type: 'post', //请求方式  当要提交自定义参数时，这个参数要设置成post
        secureuri: false, //是否启用安全提交，默认为false。
        fileElementId: index, // 需要上传的文件域的ID，即<input type="file">的ID。
        data: { 'assessmentIndicatorsName': target.assessmentIndicatorsName, 'assessmentDepartmentName': target.areaName },
        dataType: 'json', //服务器返回的数据类型。可以为xml,script,json,html。如果不填写，jQuery会自动判断。如果json返回的带pre,这里修改为json即可解决。
        success: function(json, status) { //提交成功后自动执行的处理函数，参数data就是服务器返回的数据。
            window.location.reload()
        },
        error: function(json, status, e) { //提交失败自动执行的处理函数。
            window.location.reload()
        }
    });
}

function getList(a, b, c) {
    $('#table').bootstrapTable({
        url: 'http://39.98.42.158/manage/getDepartmentReportedInfo', //请求后台的URL（*）
        method: 'post', //请求方式（*）
        //toolbar: '#toolbar',                //工具按钮用哪个容器
        cache: false, //是否使用缓存，默认为true，所以一般情况下需要设置一下这个属性（*）
        pagination: true, //是否显示分页（*）
        sortable: false, //是否启用排序
        sortOrder: "asc", //排序方式
        // queryParams: oTableInit.queryParams,//传递参数（*）
        sidePagination: "server", //分页方式：client客户端分页，server服务端分页（*）
        pageNumber: 1, //初始化加载第一页，默认第一页
        pageSize: 10, //每页的记录行数（*）
        pageList: [10, 25, 50, 100], //可供选择的每页的行数（*）
        search: false, //是否显示表格搜索，此搜索是客户端搜索，不会进服务端，所以，个人感觉意义不大
        strictSearch: false,
        showColumns: false, //是否显示所有的列
        showRefresh: false, //是否显示刷新按钮
        minimumCountColumns: 2, //最少允许的列数
        clickToSelect: false, //是否启用点击选中行
        height: 500, //行高，如果没有设置height属性，表格自动根据记录条数觉得表格高度
        uniqueId: "ID", //每一行的唯一标识，一般为主键列
        showToggle: false, //是否显示详细视图和列表视图的切换按钮
        cardView: false, //是否显示详细视图
        detailView: false, //是否显示父子表
        dataType: 'json',
        queryParams: function(params) {
            var queryData = {}; //如果没有额外的查询参数的话就新建一个空对象，如果有的话就先装你的查询参数
            //然后增加这两个
            // queryData.limit = params.limit;
            // queryData.offset = params.offset;
            queryData.pageNo = (params.offset / params.limit) + 1;
            queryData.pageSize = params.limit;
            if (a) {
                queryData.tScoringTableName = a
            }
            if (b) {
                queryData.leaderDepartmentName = b
            }
            queryData.reportFinish = c
            return queryData; //这个就是向服务端传递的参数对象
        },
        responseHandler: function(res) {
            if (res.code != 200) {
                return false
            }
            if (res.data) {
                var result = [];
                var rows = res.data.rows
                if (!res.data.rows) {
                    return false;
                }
                var newrow = [];
                $.each(rows, function(index, value) {
                    if (value.hasOwnProperty("reportFinish") && (value.reportFinish == "未上报")) {
					
						//{modify by wuguofang 20181205 for 增加不可以下载时的消息提示 begin 
                        //var download = '<a class="u-upload" href="jascript:void(0);"><button type="button">下载</button></a>'
                        var download='<a class="u-upload" href="javascript:message();"><button type="button">下载</button></a>'
						//modify by wuguofang 20181205 for 增加不可以下载时的消息提示 end}
						
                        var target = {};
                        if (value.hasOwnProperty('areaName')) {
                            target.assessmentDepartmentName = value.areaName
                        }
                        if (value.hasOwnProperty('assessmentIndicatorsName')) {
                            target.assessmentIndicatorsName = value.assessmentIndicatorsName
                        }
                        target = JSON.stringify(target)

                        var upload = '<a href="#" class="u-upload"><button type="button">上传</button><input  id="' + index + '" name="file" type="file" onchange=uploadData(\'' + target + '\',' + index + ')></a>'
                    } else {
					
						//{modify by wuguofang 20181205 for 解决url中文乱码问题 begin
                        //var download = '<a class="u-upload" href=http://39.98.42.158/manage/downLoadFile?assessmentDepartmentName=' + value.areaName + '&assessmentIndicatorsName=' + value.assessmentIndicatorsName + '><button type="button">下载</button></a>'
                        //var upload = '<a href="#" class="u-upload"><button type="button">上传</button></a>'
						
						var target = {};
                        if (value.hasOwnProperty('areaName')) {
                            target.assessmentDepartmentName = value.areaName
                        }
                        if (value.hasOwnProperty('assessmentIndicatorsName')) {
                            target.assessmentIndicatorsName = value.assessmentIndicatorsName
                        }
                        target = JSON.stringify(target)
						
						var searchText = 'assessmentDepartmentName='+value.areaName+'&assessmentIndicatorsName='+value.assessmentIndicatorsName;
						var	download="<a class='u-upload' href=\"#\" onclick=\"sentMessage('"+searchText+"')\">"+"<button type='button'>下载</button>"+"</a>";
						var upload=  '<a href="#" class="u-upload"><button type="button">修改</button><input  id="'+index+'" name="file" type="file" onchange=uploadData(\''+target+'\','+index+')></a>'
						
						//modify by wuguofang 20181205 for 解决url中文乱码问题 end}
                    }

                    // var upload=  '<a href="#" class="u-upload"><button type="button">上传</button><input  class="uploadData" name="upload" type="file"  dataurl=http://39.98.42.158/manage/downLoadFile?assessmentDepartmentName='+value.areaName+'&assessmentIndicatorsName='+value.assessmentIndicatorsName+ 'onchange="uploadData(this.dataurl,this)"  /></a>'data-toggle="modal"
                    // console.log(value)
                    // var upload='<a  onclick=uploadData(\''+target+'\')  class="uploadDatas" >上传</a>'
                    value.operate = download + "  " + upload;
                    newrow[index] = value;
                });
                result['rows'] = newrow
                result['total'] = res.data.totalRows
                return result;
            } else {
                return false;
            }

        },
        contentType: 'application/x-www-form-urlencoded; charset=UTF-8',
        smartDisplay: true,
        paginationLoop: true,
        striped: false,
        columns: [{
                field: 'tScoringTableName',
                title: '考核大类'
            }, {
                field: 'taskName',
                title: '重点任务'
            }, {
                field: 'assessmentIndicatorsName',
                title: '考核指标'
            },
            {
                field: 'reportFinish',
                title: '是否上报'
            },
            {
                field: 'leaderDepartmentName',
                title: '考核牵头部门'
            },
            {
                field: 'operate',
                title: '操作'
            },
        ]
    });

}
$.ajax({
    type: "Post",
    url: "http://39.98.42.158/manage/getUnreportedCount",
    // data: {username:$("#username").val(), content:$("#content").val()},
    dataType: "json",
    success: function(data) {
        if (data.code == 200) {
            $("#count").html(data.data)
        }
    },
    error: function(data) {

    }

});

getList('', '', 2)
$(document).ready(function() {
    //复选框选中
    $('.checkbox-ex input').change(function() {
	
        var checkboxVal = getCheckBoxVal()
        var radioVal = getRadioVal()
        $("#table").bootstrapTable('destroy');
        getList(checkboxVal['tScoringTableName'], checkboxVal['leaderDepartmentName'], radioVal)
    })
    $('.radios').change(function() {
        var checkboxVal = getCheckBoxVal()
        var radioVal = $(this).val()
        $("#table").bootstrapTable('destroy');
        getList(checkboxVal['tScoringTableName'], checkboxVal['leaderDepartmentName'], radioVal)
    })

})
//{add by wuguofang 20181205 for 解决url中文乱码问题 begin
function message(){
	alert("未上报");
}

function sentMessage(searchText){		
	var searchUrl =encodeURI("http://39.98.42.158/manage/downLoadFile?" + searchText); 
	//使用encodeURI编码 
	//alert(searchUrl);
	window.location.href =searchUrl; 
}
//add by wuguofang 20181205 for 解决url中文乱码问题 end}
</script>

</html>